home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 962 < prev    next >
Encoding:
Text File  |  1996-08-06  |  1.4 KB  |  48 lines

  1. Path: fido.asd.sgi.com!austern
  2. From: brettb@acti-ct.com (Brett Bergquist)
  3. Newsgroups: comp.std.c++
  4. Subject: Is it legal to use 'this' in the initializer list of a constructor
  5. Date: 04 Apr 1996 10:15:41 PST
  6. Organization: PCNet -- Connecticut's Internet Service Provider.
  7. Approved: austern@isolde.mti.sgi.com
  8. Message-ID: <3163b5ba.61651300@gateway>
  9. NNTP-Posting-Host: isolde.mti.sgi.com
  10. X-Original-Date: Thu, 04 Apr 1996 11:48:43 GMT
  11. X-Newsreader: Forte Agent .99d/32.182
  12. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  13.     iQBVAwUBMWQRzUy4NqrwXLNJAQGGhgH9GoLdc+G3dsy6+3mfyv0edabr39/K6IYr
  14.     KfJ42xxgT6179LcnV8WJOOcGmZ2LWq+VwrJVLdG+VYdgm/mGGvmUYw==
  15.     =C5au
  16. Originator: austern@isolde.mti.sgi.com
  17.  
  18. consider the following classes:
  19.  
  20.     class bar;
  21.     class foo
  22.     {
  23.       public:
  24.         foo(bar* b) : m_b(b) {}
  25.       private:
  26.         bar* m_b;
  27.     };
  28.  
  29.     class bar
  30.     {
  31.                public:
  32.         bar() : m_f(this) {}
  33. //               ^^^ is this legal
  34.       private:
  35.         const foo m_f;
  36.     };
  37.  
  38. Is the use of 'this' legal to initialize the constant foo member.  If
  39. not, how does one get a pointer to object being constructed within
  40. the constructor initializer?
  41. ---
  42. [ comp.std.c++ is moderated.  To submit articles: Try just posting with your 
  43.                 newsreader.  If that fails, use mailto:std-c++@ncar.ucar.edu
  44.   comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
  45.   Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
  46.   Comments? mailto:std-c++-request@ncar.ucar.edu 
  47. ]
  48.